import LogRocket from 'logrocket';

export function initLogRocket() {
    // 只在生产环境初始化 LogRocket
    if (import.meta.env.NODE_ENV === 'production') {
        LogRocket.init('ycmo7j/esp32-launchpad');
        const browser = navigator.userAgent;
        const os = navigator.platform;
        const device = /Mobi|Android/i.test(navigator.userAgent) ? 'Mobile' : 'Desktop';

        // 构建用户标识
        const userId = `${browser} | ${os} | ${device}`;

        LogRocket.identify(userId, {
            browser: browser,
            os: os,
            device: device,
            userAgent: navigator.userAgent,
            language: navigator.language,
            platform: navigator.platform,
            screenResolution: `${window.screen.width}x${window.screen.height}`,
            timezone: Intl.DateTimeFormat().resolvedOptions().timeZone
        });
    }
}